<script>
/**
 * leetCode 922
 * @param {number[]} nums
 * @return {number[]}
 */
 var sortArrayByParityII = function(nums) {
    const evenArr=[]
    const oddArr=[]

    for(let i=0;i<nums.length;i++){
        if(nums[i]%2==0){
            evenArr.push(nums[i]);
        }else{
            oddArr.push(nums[i]);
        }
    }
    for(let i=0;i<nums.length;i++){
        if(i%2==0){
            nums[i]=evenArr.shift();
        }else{
            nums[i]=oddArr.shift();
        }
    }
};



const nums=[0,2,4,1,3,5];
sortArrayByParityII(nums);
console.log(nums);


</script>